package top.tangyh.lamp.care.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import top.tangyh.basic.base.R;
import top.tangyh.basic.interfaces.echo.EchoService;
import top.tangyh.basic.base.controller.SuperController;
import top.tangyh.lamp.care.service.BCareIsbarHandoverService;
import top.tangyh.lamp.care.entity.BCareIsbarHandover;
import top.tangyh.lamp.care.vo.query.CareISBARQueryInVO;
import top.tangyh.lamp.care.vo.result.IsbarIOOutVo;
import top.tangyh.lamp.care.vo.result.IsbarPgRecordDTO;
import top.tangyh.lamp.care.vo.result.PageOutputDTO;
import top.tangyh.lamp.care.vo.save.BCareIsbarHandoverSaveVO;
import top.tangyh.lamp.care.vo.save.CareISBARHandoverInVO;
import top.tangyh.lamp.care.vo.update.BCareIsbarHandoverUpdateVO;
import top.tangyh.lamp.care.vo.result.BCareIsbarHandoverResultVO;
import top.tangyh.lamp.care.vo.query.BCareIsbarHandoverPageQuery;

import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 * 前端控制器
 * ISBAR护理交班表
 * </p>
 *
 * @author zqb
 * @date 2024-08-12 10:28:25
 * @create [2024-08-12 10:28:25] [zqb] [代码生成器生成]
 */
@Slf4j
@RequiredArgsConstructor
@Validated
@RestController
@RequestMapping("/isbar")
@Tag(name = "ISBAR护理交班")
public class BCareIsbarHandoverController {
//    extends SuperController<BCareIsbarHandoverService, Long, BCareIsbarHandover
//            , BCareIsbarHandoverSaveVO, BCareIsbarHandoverUpdateVO, BCareIsbarHandoverPageQuery, BCareIsbarHandoverResultVO>
//    private final EchoService echoService;
//    @Override
//    public EchoService getEchoService() {
//        return echoService;
//    }

    private final BCareIsbarHandoverService bCareIsbarHandoverService;

    @Operation(summary = "新交班接口")
    @GetMapping("/last")
    public R<BCareIsbarHandoverResultVO> queryLastRecord(@Parameter(name = "currentDate", description = "查询日期时间 精确到天的13位时间戳", required = true) @RequestParam Long currentDate) {
        return R.success(bCareIsbarHandoverService.queryLast(currentDate));
    }

    @Operation(summary = "历史交班记录接口")
    @GetMapping("/list")
    public R<PageOutputDTO<BCareIsbarHandoverResultVO>> queryRecords(CareISBARQueryInVO queryInVO) {
        return R.success(bCareIsbarHandoverService.queryRecords(queryInVO));
    }

    @Operation(summary = "交班记录保存接口")
    @PostMapping("/save")
    public R save(@RequestBody @Valid CareISBARHandoverInVO inVo) {
        bCareIsbarHandoverService.save(inVo);
        return R.success();
    }


    @Operation(summary = "删除接口")
    @DeleteMapping("/delete")
    public R deleted(@Parameter(description = "id", required = true) @RequestParam Long id) {
        bCareIsbarHandoverService.delete(id);
        return R.success();
    }

    @Operation(summary = "手术数量接口：默认为当天8：00到第二天7：59")
    @GetMapping("/opera")
    public R<Long> operaCount(@Parameter(description = "开始时间") @RequestParam(value = "startTime", required = false) Long startTime,
                              @Parameter(description = "结束时间") @RequestParam(value = "endTime", required = false) Long endTime) {
        return R.success(bCareIsbarHandoverService.operaCount(startTime, endTime));
    }

    @Operation(summary = "病人出入量")
    @GetMapping("/inout")
    public R<IsbarIOOutVo> inOut(@Parameter(description = "住院号", required = true) @RequestParam(value = "hospitalNumber") String hospitalNumber,
                                 @Parameter(description = "开始时间", required = true) @RequestParam(value = "startTime") Long startTime,
                                 @Parameter(description = "结束时间", required = true) @RequestParam(value = "endTime") Long endTime) {
        return R.success(bCareIsbarHandoverService.inout(hospitalNumber, startTime, endTime));
    }


    @Operation(summary = "特别提醒：默认为当天8：00到第二天7：59")
    @GetMapping("/remind")
    public R<List<IsbarPgRecordDTO>> remind(@Parameter(description = "住院号", required = true) @RequestParam(value = "hospitalNumber") String hospitalNumber,
                                            @Parameter(description = "开始时间") @RequestParam(value = "startTime", required = false) Long startTime,
                                            @Parameter(description = "结束时间") @RequestParam(value = "endTime", required = false) Long endTime) {
        return R.success(bCareIsbarHandoverService.remind(hospitalNumber, startTime, endTime));
    }



}


